package com.androidx.p013lv.base.utils;

import android.animation.ObjectAnimator;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.androidx.p013lv.base.C1010R;
import com.androidx.p013lv.base.bean.novel.SearchNovelHotRecommendBean;
import java.util.List;

/* renamed from: com.androidx.lv.base.utils.ScrollTextView */
public class ScrollTextView extends LinearLayout {
    private int endY1;
    private int endY2;
    private boolean hasPostRunnable;
    private boolean isShow;
    private List<SearchNovelHotRecommendBean.SearchNovelHotRecommendData> list;
    private TextView mBannerTV1;
    private TextView mBannerTV2;
    private int offsetY;
    private int position;
    private Runnable runnable;
    private int startY1;
    private int startY2;

    static /* synthetic */ int access$108(ScrollTextView scrollTextView) {
        int i = scrollTextView.position;
        scrollTextView.position = i + 1;
        return i;
    }

    public ScrollTextView(Context context) {
        this(context, null);
    }

    public ScrollTextView(Context context, AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    public ScrollTextView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        this.isShow = false;
        this.position = 0;
        this.offsetY = 100;
        this.hasPostRunnable = false;
        View inflate = LayoutInflater.from(context).inflate(C1010R.C1015layout.widget_scroll_text_layout, this);
        this.mBannerTV1 = (TextView) inflate.findViewById(C1010R.C1013id.tv_banner1);
        this.mBannerTV2 = (TextView) inflate.findViewById(C1010R.C1013id.tv_banner2);
        this.runnable = new Runnable() {
            /* class com.androidx.p013lv.base.utils.ScrollTextView.RunnableC10581 */

            public void run() {
                ScrollTextView scrollTextView = ScrollTextView.this;
                scrollTextView.isShow = !scrollTextView.isShow;
                if (ScrollTextView.this.position == ScrollTextView.this.list.size() - 1) {
                    ScrollTextView.this.position = 0;
                }
                if (ScrollTextView.this.isShow) {
                    ScrollTextView.this.mBannerTV1.setText(((SearchNovelHotRecommendBean.SearchNovelHotRecommendData) ScrollTextView.this.list.get(ScrollTextView.access$108(ScrollTextView.this))).getFictionTitle());
                    ScrollTextView.this.mBannerTV2.setText(((SearchNovelHotRecommendBean.SearchNovelHotRecommendData) ScrollTextView.this.list.get(ScrollTextView.this.position)).getFictionTitle());
                } else {
                    ScrollTextView.this.mBannerTV2.setText(((SearchNovelHotRecommendBean.SearchNovelHotRecommendData) ScrollTextView.this.list.get(ScrollTextView.access$108(ScrollTextView.this))).getFictionTitle());
                    ScrollTextView.this.mBannerTV1.setText(((SearchNovelHotRecommendBean.SearchNovelHotRecommendData) ScrollTextView.this.list.get(ScrollTextView.this.position)).getFictionTitle());
                }
                ScrollTextView scrollTextView2 = ScrollTextView.this;
                scrollTextView2.startY1 = scrollTextView2.isShow ? 0 : ScrollTextView.this.offsetY;
                ScrollTextView scrollTextView3 = ScrollTextView.this;
                scrollTextView3.endY1 = scrollTextView3.isShow ? -ScrollTextView.this.offsetY : 0;
                ObjectAnimator.ofFloat(ScrollTextView.this.mBannerTV1, "translationY", (float) ScrollTextView.this.startY1, (float) ScrollTextView.this.endY1).setDuration(300L).start();
                ScrollTextView scrollTextView4 = ScrollTextView.this;
                scrollTextView4.startY2 = scrollTextView4.isShow ? ScrollTextView.this.offsetY : 0;
                ScrollTextView scrollTextView5 = ScrollTextView.this;
                scrollTextView5.endY2 = scrollTextView5.isShow ? 0 : -ScrollTextView.this.offsetY;
                ObjectAnimator.ofFloat(ScrollTextView.this.mBannerTV2, "translationY", (float) ScrollTextView.this.startY2, (float) ScrollTextView.this.endY2).setDuration(300L).start();
                ScrollTextView scrollTextView6 = ScrollTextView.this;
                scrollTextView6.postDelayed(scrollTextView6.runnable, 3000);
            }
        };
    }

    public List<SearchNovelHotRecommendBean.SearchNovelHotRecommendData> getList() {
        return this.list;
    }

    public void setList(List<SearchNovelHotRecommendBean.SearchNovelHotRecommendData> list2) {
        if (list2 != null) {
            this.list = list2;
        }
    }

    public void startScroll() {
        if (this.mBannerTV1 != null) {
            List<SearchNovelHotRecommendBean.SearchNovelHotRecommendData> list2 = this.list;
            if (list2 == null || list2.size() <= 1) {
                this.hasPostRunnable = false;
                return;
            }
            this.mBannerTV1.setText(this.list.get(0).getFictionTitle());
            if (!this.hasPostRunnable) {
                this.hasPostRunnable = true;
                postDelayed(this.runnable, 3000);
            }
        }
    }

    public void stopScroll() {
        removeCallbacks(this.runnable);
        this.hasPostRunnable = false;
    }
}
